package org.lex.dbq.view.template;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;

public class NewDriverDialog extends Dialog {

	public static void main(String[] args) {
		new NewDriverDialog(null).open();
		Display.getCurrent().dispose();
	}

	private Text aliasName = null;
	private Combo driver = null;
	private Button newDriver = null;
	private Text url = null;
	private Text userName = null;
	private Text password = null;

	public NewDriverDialog(Shell parentShell) {
		super(parentShell);
		this.setBlockOnOpen(true);
	}

	@Override
	protected Control createDialogArea(Composite parent) {
		this.getShell().setText("Open ...");

		GridLayout layout = new GridLayout();
		layout.makeColumnsEqualWidth = false;
		layout.numColumns = 4;
		layout.horizontalSpacing = 5;
		layout.verticalSpacing = 11;

		Composite form = new Composite(parent, SWT.NONE);
		form.setLayout(layout);
		GridData g = null;
		{
			Label prompt = new Label(form, SWT.LEFT);
			prompt.setText("Add new alias");
			g = new GridData(GridData.FILL_HORIZONTAL);
			g.verticalSpan = 1;
			g.horizontalSpan = 4;
			prompt.setLayoutData(g);

			Label aliasNameLabel = new Label(form, SWT.LEFT);
			aliasNameLabel.setText("Alias name");
			g = new GridData();
			g.verticalSpan = 1;
			g.horizontalSpan = 1;
			aliasNameLabel.setLayoutData(g);

			aliasName = new Text(form, SWT.BORDER);
			g = new GridData(GridData.FILL_HORIZONTAL);
			g.verticalSpan = 1;
			g.horizontalSpan = 3;
			aliasName.setLayoutData(g);
		}
		{
			Label label = new Label(form, SWT.NONE);
			label.setText("Driver");
			g = new GridData();
			g.verticalSpan = 1;
			g.horizontalSpan = 1;
			label.setLayoutData(g);

			driver = new Combo(form, SWT.NONE);
			g = new GridData(GridData.FILL_HORIZONTAL);
			g.verticalSpan = 1;
			g.horizontalSpan = 2;
			driver.setLayoutData(g);

			newDriver = new Button(form, SWT.PUSH);
			newDriver.setText("New");
			g = new GridData();
			g.verticalSpan = 1;
			g.horizontalSpan = 1;
			newDriver.setLayoutData(g);
		}
		{
			Label label = new Label(form, SWT.NONE);
			label.setText("URL");
			g = new GridData();
			g.verticalSpan = 1;
			g.horizontalSpan = 1;
			label.setLayoutData(g);

			url = new Text(form, SWT.BORDER);
			g = new GridData(GridData.FILL_HORIZONTAL);
			g.verticalSpan = 1;
			g.horizontalSpan = 3;
			url.setLayoutData(g);
		}
		{
			Label label = new Label(form, SWT.NONE);
			label.setText("User Name");
			g = new GridData();
			g.verticalSpan = 1;
			g.horizontalSpan = 1;
			label.setLayoutData(g);

			userName = new Text(form, SWT.BORDER);
			g = new GridData(GridData.FILL_HORIZONTAL);
			g.verticalSpan = 1;
			g.horizontalSpan = 3;
			userName.setLayoutData(g);
		}
		{
			Label label = new Label(form, SWT.NONE);
			label.setText("Password");
			g = new GridData();
			g.verticalSpan = 1;
			g.horizontalSpan = 1;
			label.setLayoutData(g);

			password = new Text(form, SWT.BORDER | SWT.PASSWORD);
			g = new GridData(GridData.FILL_HORIZONTAL);
			g.verticalSpan = 1;
			g.horizontalSpan = 3;
			password.setLayoutData(g);
		}
		return parent;
	}
}
